<HTML><HEAD><TITLE>cs_random_worst(+CS, -Cstr)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(tentative)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>cs_random_worst(+CS, -Cstr)</H1>
Get random worst violated constraint from the constraint set
<DL>
<DT><EM>CS</EM></DT>
<DD>Constraint set
</DD>
<DT><EM>Cstr</EM></DT>
<DD>A constraint term (output)
</DD>
</DL>
<H2>Description</H2>

	<P>
	Returns a worst violated constraint from the constraint set, i.e.
	a constraint that has maximum violation count among the constraints
	in the set. If there are several, a random one is picked.
	</P><P>
	If the constraints were added with aliases (see :~ /2),
	the alias term is retrieved instead of the constraint goal.
	</P>
    
<H3>Modes and Determinism</H3><UL>
<LI>cs_random_worst(+, -) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if there is no violated constraint in the set
<H2>Examples</H2>
<PRE>
    ?- [X, Y] tent_set [3, 4], CS :~ (X $= Y), CS :~ (X $\= Y), cs_random_worst(CS, C).
    X = X{3 -&gt; 0}
    Y = Y{4 -&gt; 0}
    CS = constraint_set(TotalVio{1 -&gt; 0}, ...)
    C = X{3 -&gt; 0} $= Y{4 -&gt; 0}
    There are 2 delayed goals.
    Yes (0.00s cpu)
    </PRE>
<H2>See Also</H2>
<A HREF="../../lib/tentative/cs_random_violated-2.html">cs_random_violated / 2</A>, <A HREF="../../lib/tentative/cs_all_worst-2.html">cs_all_worst / 2</A>
</BODY></HTML>
